package com.project.service.addressService.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.bean.AddressBean;
import com.project.mapper.addressMapper.IAddressMapper;
import com.project.service.addressService.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class AddressServiceImpl implements IAddressService {
    @Autowired
    private IAddressMapper addressMapper;

    @Override
    public List<AddressBean> getAll(int userId) {
        return addressMapper.findAll(userId);
    }

    @Override
    public PageInfo<AddressBean> findAll(int pageNO, int userId) {
        PageHelper.startPage(pageNO,PAGESIZE);
        return PageInfo.of(addressMapper.findAll(userId));
    }

    @Override
    public void add(AddressBean addressBean, int userId) {
        addressMapper.add(addressBean,userId);
    }

    @Override
    public void del(int id) {
        addressMapper.del(id);
    }

    @Override
    public void update(int id, String name, String tel,String address) {
        addressMapper.update(id, name, tel,address);
    }
}
